package com.xms.sdk.core.query;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * <p>
 * QueryByAttribute
 * </p>
 *
 * @author migo
 * @since 2021/9/1
 */
public class QueryByAttribute extends QueryBase{
    public void QueryByAttribute() {

    }
    public QueryByAttribute(String entityName)
    {
        super.EntityName = entityName;
    }

    public ColumnSet ColumnSet = new ColumnSet();

    public PagingInfo PageInfo;

    public List<OrderExpression> Orders;

    public List<String> Attributes;

    public List<Object> Values;

    public QueryByAttribute addAttribute(String... attribute){
        if(this.Attributes == null) this.Attributes = new ArrayList<>();
        this.Attributes.addAll(Arrays.asList(attribute));
        return this;
    }

    public QueryByAttribute addValue(Object... value){
        if(this.Values == null) this.Values = new ArrayList<>();
        this.Values.addAll(Arrays.asList(value));
        return this;
    }

    public QueryByAttribute addCondition(String attribute, Object value){
        this.addAttribute(attribute);
        this.addValue(value);
        return this;
    }

    public QueryByAttribute addOrder(String attributeName, OrderType orderType)
    {
        this.Orders.add(new OrderExpression(attributeName, orderType));
        return this;
    }
}
